home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / wbgames / aniso / aniso.s < prev    next >
Text File  |  1996-04-07  |  14KB  |  828 lines

  1. ;    Aniso - a small puzzle game
  2. ;    Copyright 1992 Barry McConnell
  3. ;    Set TAB stops to 10!
  4.  
  5.     include    exec/exec_lib.i
  6.     include    exec/execbase.i
  7.     include    exec/memory.i
  8.     include    intuition/intuition_lib.i
  9.     include    dos/dos_lib.i
  10.     include    dos/dosextens.i
  11.     include    graphics/graphics_lib.i
  12.     include    libraries/gadtools_lib.i
  13.     
  14.     include    graphics/gfxbase.i
  15.     include    intuition/intuition.i
  16.     include    libraries/gadtools.i
  17.  
  18.  
  19. CALLGAD    MACRO
  20.     move.l    _GadBase,a6
  21.     jsr    _LVO\1(a6)
  22.     ENDM
  23.  
  24.     SECTION    Aniso,CODE
  25.  
  26.     movem.l    d0/a0,-(a7)
  27.     clr.l    ReturnMsg
  28.     movea.w    #0,a1
  29.     CALLEXEC    FindTask
  30.     movea.l    d0,a4
  31.     tst.l    pr_CLI(a4)        started from WB or CLI?
  32.     bne.s    SkipWB
  33.     lea    pr_MsgPort(a4),a0
  34.     CALLEXEC    WaitPort
  35.     lea    pr_MsgPort(a4),a0
  36.     CALLEXEC    GetMsg
  37.     move.l    d0,ReturnMsg        save it for later reply
  38. SkipWB    movem.l    (a7)+,d0/a0
  39.     bsr.s    Main
  40.     move.l    d0,-(a7)            save exit code
  41.     tst.l    ReturnMsg            started from CLI?
  42.     beq.s    End
  43.     CALLEXEC    Forbid
  44.     move.l    ReturnMsg,a1
  45.     CALLEXEC    ReplyMsg
  46. End    move.l    (a7)+,d0
  47.     rts
  48.     
  49. Main    lea    IntName,a1
  50.     moveq.l    #37,d0
  51.     CALLEXEC    OpenLibrary
  52.     tst.l    d0
  53.     beq    end
  54.  
  55.     move.l    d0,_IntuitionBase
  56.  
  57.     lea    DosName,a1
  58.     moveq.l    #37,d0
  59.     CALLEXEC    OpenLibrary
  60.     tst.l    d0
  61.     beq    closeint
  62.  
  63.     move.l    d0,_DOSBase    
  64.  
  65.     lea    GadName,a1
  66.     moveq.l    #37,d0
  67.     CALLEXEC    OpenLibrary
  68.     tst.l    d0
  69.     beq    closedos
  70.  
  71.     move.l    d0,_GadBase    
  72.  
  73.     lea    GfxName,a1
  74.     moveq.l    #37,d0
  75.     CALLEXEC    OpenLibrary
  76.     tst.l    d0
  77.     beq    closegad
  78.  
  79.     move.l    d0,_GfxBase
  80.  
  81.     movea.l    d0,a0
  82.     move.l    gb_DefaultFont(a0),a1
  83.     move.l    a1,SysFont
  84.     lea    DefFont,a2
  85.     move.l    LN_NAME(a1),(a2)+
  86.     move.w    tf_YSize(a1),(a2)
  87.  
  88.     movea.w    #0,a0
  89.     CALLINT    LockPubScreen
  90.     tst.l    d0
  91.     beq    closegfx
  92.  
  93.     move.l    d0,PubScr
  94.  
  95.     movea.l    d0,a3
  96.     move.l    sc_Font(a3),a0
  97.     CALLGRAF    OpenFont
  98.     tst.l    d0
  99.     beq    unlock
  100.  
  101.     move.l    d0,ScrFont
  102.  
  103.     move.l    d0,a1
  104.     CALLGRAF    CloseFont
  105.  
  106.     movea.l    a3,a0
  107.     movea.w    #0,a1
  108.     CALLGAD    GetVisualInfoA
  109.     tst.l    d0
  110.     beq    unlock
  111.  
  112.     move.l    d0,VisInfo
  113.  
  114. Init    movea.l    SysFont,a0
  115.     movea.l    ScrFont,a1
  116.     move.w    tf_XSize(a0),d3        width of system default font
  117.     move.w    tf_YSize(a0),d4        height of system default font
  118.     move.w    tf_YSize(a1),d5        height of default screen font
  119.     move.w    d5,sfsize
  120.  
  121.     move.w    Size,d2
  122.     move.w    d2,d0
  123.     mulu    #6,d0
  124.     addi.w    #9,d0
  125.     mulu    d3,d0
  126.     addi.w    #36,d0
  127.     move.w    d2,d1
  128.     mulu    #8,d1
  129.     add.w    d1,d0
  130.     move.l    d0,winwidth
  131.  
  132.     move.w    d2,d0
  133.     addq.w    #1,d0
  134.     mulu    d4,d0
  135.     addi.w    #27,d0
  136.     move.w    d2,d1
  137.     mulu    #10,d1
  138.     add.w    d1,d0
  139.     add.w    d5,d0            allow room for title bar
  140.     move.l    d0,winheight
  141.  
  142.     move.w    d2,d0
  143.     mulu    d0,d0
  144.     add.w    d0,d0
  145.     move.l    d0,d6
  146.     addi.w    #4,d0
  147.     mulu    #30,d0            30 bytes per NewGadget structure
  148.     move.l    d0,Mem1
  149.     move.l    #MEMF_ANY!MEMF_CLEAR,d1
  150.     CALLEXEC    AllocMem
  151.     tst.l    d0
  152.     beq    freevi
  153.  
  154.     move.l    d0,GadMem
  155.     move.l    d6,d0
  156.     add.w    d0,d0
  157.     move.l    d0,Mem2
  158.     move.l    #MEMF_ANY!MEMF_CLEAR,d1
  159.     CALLEXEC    AllocMem
  160.     tst.l    d0
  161.     beq    freegmem
  162.  
  163.     move.l    d0,TextMem
  164.     move.w    d3,d0
  165.     mulu    #3,d0
  166.     addq.w    #4,d0            width of one gadget
  167.     move.w    d0,width
  168.     mulu    d2,d0
  169.     move.w    d0,nwidth            width of n gadgets
  170.  
  171.     move.w    d4,d0
  172.     addi.w    #10,d0            height of one gadget
  173.     move.w    d0,height
  174.     mulu    d2,d0            height of n gadgets
  175.     move.w    d0,nheight        height of n gadgets
  176.  
  177.     move.w    d2,d0
  178.     mulu    d0,d0
  179.     add.w    d0,d0            memory taken by text by n*n buttons
  180.     move.w    d0,ntext
  181.  
  182.     move.w    Size,d5
  183.     mulu    d5,d5
  184.     mulu    #30,d5            memory taken by n*n NewGadgets
  185.  
  186.     movea.l    GadMem,a0
  187.     movea.l    TextMem,a1
  188.     moveq.w    #10,d1            gadget ID
  189.     clr.w    d7            row counter
  190. row    clr.w    d6            column counter
  191. column    movem.l    a0-a1,-(a7)
  192.  
  193.     move.w    width,d0
  194.     mulu    d6,d0
  195.     addq.w    #8,d0
  196.     move.w    d0,(a0)            left (text)
  197.     add.w    nwidth,d0
  198.     addi.w    #10,d0
  199.     move.w    d0,0(a0,d5)        left (button)
  200.     adda.w    #2,a0
  201.  
  202.     move.w    height,d0
  203.     mulu    d7,d0
  204.     addq.w    #7,d0
  205.     add.w    sfsize,d0
  206.     move.w    d0,(a0)            top (text)
  207.     move.w    d0,0(a0,d5)        top (button)
  208.     adda.w    #2,a0
  209.  
  210.     move.w    width,d0
  211.     subq.w    #4,d0
  212.     move.w    d0,(a0)            width (text)
  213.     move.w    d0,0(a0,d5)        width (button)
  214.     adda.w    #2,a0
  215.  
  216.     move.w    height,d0
  217.     subq.w    #4,d0
  218.     move.w    d0,(a0)            height (text)
  219.     move.w    d0,0(a0,d5)        height (button)
  220.     adda.w    #2,a0
  221.  
  222.     move.l    a1,(a0)            text (text)
  223.     adda.w    ntext,a1
  224.     move.l    a1,0(a0,d5)        text (button)
  225.     adda.w    #4,a0
  226.  
  227.     lea    DefFont,a2
  228.     move.l    a2,(a0)            Default Font (text)
  229.     move.l    a2,0(a0,d5)        Default Font (button)
  230.     adda.w    #4,a0
  231.  
  232.     move.w    d1,(a0)            ID (text)
  233.     move.w    d2,d0
  234.     mulu    d0,d0
  235.     add.w    d1,d0
  236.     move.w    d0,0(a0,d5)        ID (button)
  237.     adda.w    #2,a0
  238.     addq.w    #1,d1
  239.  
  240.     moveq.l    #PLACETEXT_IN,d0
  241.     move.l    d0,(a0)            flags (text)
  242.     move.l    d0,0(a0,d5)        flags (button)
  243.     adda.w    #4,a0
  244.  
  245.     move.l    VisInfo,d0
  246.     move.l    d0,(a0)            Visual Info (text)
  247.     move.l    d0,0(a0,d5)        Visual Info (button)
  248.     adda.w    #4,a0
  249.  
  250.     move.l    #TEXT_KIND,(a0)        user data (text)
  251.     move.l    #BUTTON_KIND,0(a0,d5)    user data (button)
  252.  
  253.     movem.l    (a7)+,a0-a1
  254.     adda.w    #30,a0
  255.     adda.w    #2,a1
  256.     addq.b    #1,d6
  257.     cmp.b    d2,d6
  258.     bne    column
  259.     addq.b    #1,d7
  260.     cmp.b    d2,d7
  261.     bne    row
  262.  
  263.     adda.l    d5,a0
  264.     movea.l    a0,a1
  265.  
  266.     lea    Buttons,a0
  267.     move.w    nheight,d0
  268.     add.w    #15,d0
  269.     add.w    sfsize,d0
  270.     move.w    d0,2(a0)            top
  271.     move.w    d0,32(a0)
  272.     move.w    d0,62(a0)
  273.  
  274.     move.w    d3,d0
  275.     mulu    #8,d0
  276.     move.w    d0,d6
  277.     move.w    d0,4(a0)            width
  278.     move.w    d0,34(a0)
  279.     move.w    d0,64(a0)
  280.  
  281.     move.w    d4,d0
  282.     addq.w    #6,d0
  283.     move.w    d0,6(a0)            height
  284.     move.w    d0,36(a0)
  285.     move.w    d0,66(a0)
  286.     move.w    d0,96(a0)
  287.  
  288.     move.l    VisInfo,d0
  289.     move.l    d0,22(a0)            VisualInfo
  290.     move.l    d0,52(a0)
  291.     move.l    d0,82(a0)
  292.     move.l    d0,112(a0)
  293.  
  294.     move.w    d2,d0
  295.     mulu    #6,d0
  296.     subi.w    #15,d0
  297.     mulu    d3,d0
  298.     add.w    #20,d0
  299.     move.w    d2,d1
  300.     mulu    #8,d1
  301.     add.w    d1,d0
  302.     ror.l    #1,d0            distance between each button
  303.  
  304.     move.w    d6,d1
  305.     addi.w    #8,d1
  306.     add.w    d0,d1
  307.     move.w    d1,30(a0)            left (2nd button)
  308.     add.w    d6,d1
  309.     add.w    d0,d1
  310.     move.w    d1,60(a0)            left (3rd button)
  311.  
  312.     move.w    nwidth,d0
  313.     add.w    d0,d0
  314.     addi.w    #28,d0
  315.     move.w    d0,90(a0)            left (cycle)
  316.  
  317.     move.w    height,d0
  318.     addq.w    #7,d0
  319.     add.w    sfsize,d0
  320.     move.w    d0,92(a0)            top (cycle)
  321.  
  322.     move.w    d3,d0
  323.     mulu    #9,d0
  324.     move.w    d0,94(a0)            width (cycle)
  325.  
  326.     moveq.l    #120,d0
  327.     CALLEXEC    CopyMem
  328.  
  329.     move.w    Size,d0
  330.     move.w    d0,SizeCopy
  331.     subq.w    #3,d0
  332.     move.l    d0,CycActive
  333.  
  334.     bsr    Shuffle
  335.  
  336.     lea    glist,a0
  337.     CALLGAD    CreateContext
  338.     tst.l    d0
  339.     beq    freetmem
  340.  
  341.     movea.l    d0,a0
  342.     movea.l    GadMem,a1
  343.     move.w    Size,d2
  344.     mulu    d2,d2
  345.     add.w    d2,d2
  346.     addi.w    #4,d2
  347.     lea    Tag1,a2
  348.     clr.l    FirstBox
  349.     clr.l    FirstBut
  350.  
  351. gadloop    move.l    26(a1),d0            kind
  352.     move.l    d0,-(a7)
  353.     movea.l    a1,a5
  354.     cmpi.w    #4,d2
  355.     bne    nochange
  356.     lea    Tag2,a2
  357. nochange    CALLGAD    CreateGadgetA
  358.     tst.l    d0
  359.     bne    createok
  360.     move.l    (a7)+,d0
  361.     bra    freegads
  362.  
  363. createok    movea.l    a5,a1
  364.     adda.w    #30,a1
  365.     movea.l    d0,a0
  366.     tst.l    FirstBox
  367.     bne    notbox
  368.     move.l    a0,FirstBox
  369. notbox    move.l    (a7)+,d0
  370.     cmpi.l    #BUTTON_KIND,d0
  371.     bne    notbutton
  372.     tst.l    FirstBut
  373.     bne    notbutton
  374.     move.l    a0,FirstBut
  375. notbutton    subq.w    #1,d2
  376.     bne    gadloop
  377.  
  378.     move.l    d0,CycleGad
  379.     movea.w    #0,a0
  380.     lea    WinTags,a1
  381.     CALLINT    OpenWindowTagList
  382.     tst.l    d0
  383.     beq    freegads
  384.  
  385.     move.l    d0,MyWindow
  386.     movea.l    d0,a0
  387.     move.l    wd_UserPort(a0),MyIdcmp
  388.     movea.l    MyWindow,a0
  389.     CALLINT    ActivateWindow
  390.  
  391. sleep    movea.l    MyIdcmp,a0
  392.     CALLEXEC    WaitPort
  393.  
  394. loop    movea.l    MyIdcmp,a0
  395.     CALLGAD    GT_GetIMsg        something happened!
  396.     tst.l    d0
  397.     beq    sleep            received all messages
  398.     movea.l    d0,a1
  399.     move.l    im_Class(a1),d3        what exactly happened?
  400.     move.w    im_Qualifier(a1),d4        with what?
  401.     move.w    im_Code(a1),d5        its code
  402.     movea.l    im_IAddress(a1),a2        and to what?
  403.     CALLGAD    GT_ReplyIMsg
  404.  
  405.     cmpi.l    #CLOSEWINDOW,d3
  406.     bne    noclose
  407. finish    move.w    #1,Terminate
  408.     bra    closewind
  409.  
  410. noclose    cmpi.l    #VANILLAKEY,d3
  411.     bne    nokey
  412.     cmpi.w    #"n",d5
  413.     beq    new
  414.     cmpi.w    #"r",d5
  415.     beq    retry
  416.     cmpi.w    #"q",d5
  417.     beq    finish
  418.     bra    loop
  419.  
  420. nokey    move.w    gg_GadgetID(a2),d0
  421.     cmpi.w    #200,d0
  422.     bge    button
  423.     cmpi.w    #10,d0
  424.     blt    loop
  425.  
  426.     move.w    Size,d1
  427.     mulu    d1,d1
  428.     sub.w    d1,d0
  429.     sub.w    #10,d0            button number
  430.     bsr    IncSquare
  431.  
  432. update    movea.l    FirstBut,a0
  433.     movea.l    MyWindow,a1
  434.     movea.w    #0,a2
  435.     move.w    Size,d0
  436.     mulu    d0,d0
  437.     CALLINT    RefreshGList
  438.  
  439.     move.w    Size,d0
  440.     mulu    d0,d0
  441.     cmp.w    Count,d0
  442.     bne    loop
  443.     bsr    TestWin
  444.     bra    loop
  445.  
  446. button    cmpi.w    #200,d0
  447.     beq    new
  448.     cmpi.w    #201,d0
  449.     beq    retry
  450.     cmpi.w    #202,d0
  451.     beq    finish
  452.     cmpi.w    #203,d0
  453.     bne    loop
  454.  
  455.     move.w    SizeCopy,d0
  456.     and.b    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d4
  457.     beq    cycadd
  458.     subq.w    #1,d0
  459.     cmp.w    #2,d0
  460.     bne    endcyc
  461.     move.w    #8,d0
  462.     bra    endcyc
  463. cycadd    addq.w    #1,d0
  464.     cmp.w    #9,d0
  465.     bne    endcyc
  466.     move.w    #3,d0
  467. endcyc    move.w    d0,SizeCopy
  468.     bra    loop
  469.  
  470. new    move.w    SizeCopy,Size
  471.     move.w    #0,Terminate
  472.     movea.l    MyWindow,a0
  473.     lea    WinTags,a1
  474.     move.w    gg_LeftEdge(a0),6(a1)
  475.     move.w    gg_TopEdge(a0),14(a1)
  476.     bra    closewind
  477.  
  478. retry    bsr    Clear
  479.     bra    update
  480.  
  481. closewind    movea.l    MyWindow,a0
  482.     CALLINT    CloseWindow
  483. freegads    lea    glist,a0
  484.     CALLGAD    FreeGadgets
  485. freetmem    move.l    Mem2,d0
  486.     movea.l    TextMem,a1
  487.     CALLEXEC    FreeMem
  488. freegmem    move.l    Mem1,d0
  489.     movea.l    GadMem,a1
  490.     CALLEXEC    FreeMem
  491.     tst.w    Terminate
  492.     beq    Init
  493. freevi    move.l    VisInfo,a0
  494.     CALLGAD    FreeVisualInfo
  495. unlock    movea.w    #0,a0
  496.     movea.l    PubScr,a1
  497.     CALLINT    UnlockPubScreen
  498. closegfx    move.l    _GfxBase,a1
  499.     CALLEXEC    CloseLibrary
  500. closegad    move.l    _GadBase,a1
  501.     CALLEXEC    CloseLibrary
  502. closedos    move.l    _DOSBase,a1
  503.     CALLEXEC    CloseLibrary
  504. closeint    move.l    _IntuitionBase,a1
  505.     CALLEXEC    CloseLibrary
  506. end    rts
  507.  
  508. ;    Initialise the random seed
  509.  
  510. InitRand    movem.l    d0-d1/a0,-(a7)
  511.     movea.l    4,a0
  512.     move.l    IdleCount(a0),d0
  513.     move.l    DispCount(a0),d1
  514.     rol.l    #8,d1
  515.     rol.l    #8,d1
  516.     eor.l    d0,d1
  517.     move.l    d1,Rand
  518.     movem.l    (a7)+,d0-d1/a0
  519.     rts
  520.  
  521. ;    Get a random number between d0.b = 0..n-1 and reseed. Returns number in d2.b.
  522.  
  523. GetRand    movem.l    d0-d1/d3/a0,-(a7)
  524.  
  525.     clr.w    d1
  526.     move.b    d0,d1
  527.     move.w    d1,d0
  528.     move.l    Rand,d1
  529.     clr.l    d2
  530.     move.b    d1,d2
  531.     divu    d0,d2
  532.     ror.l    #8,d2
  533.     ror.l    #8,d2            get remainder
  534.     andi.l    #255,d2            mask off upper 24 bits
  535.     ror.l    #8,d1
  536.     eori.l    #$b798a43f,d1
  537.     movea.l    4,a0
  538.     move.l    DispCount(a0),d3
  539.     eor.l    d3,d1
  540.     move.l    d1,Rand
  541.  
  542.     movem.l    (a7)+,d0-d1/d3/a0
  543.     rts
  544.  
  545. ;    Increments the square d0.b and its neighbours (if necessary). Returns d4.b=0 if unsuccessful
  546. ;    (ie. square already occupied).
  547.  
  548. IncSquare    movem.l    d0-d3/a0,-(a7)
  549.  
  550.     clr.l    d1
  551.     move.b    d0,d1
  552.     move.w    d1,d0
  553.     divu    Size,d1            row
  554.     move.w    d1,d3
  555.     mulu    Size,d3
  556.     move.w    d0,d2
  557.     sub.w    d3,d2            column
  558.  
  559.     move.b    #1,d4
  560.     bsr    inc
  561.     tst.b    d4
  562.     beq    endincsq
  563.  
  564.     addq.w    #1,Count
  565.     clr.b    d4
  566.     subq.w    #1,d1
  567.     bsr    inc
  568.     addq.w    #2,d1
  569.     bsr    inc
  570.     subq.w    #1,d1
  571.     subq.w    #1,d2
  572.     bsr    inc
  573.     addq.w    #2,d2
  574.     bsr    inc
  575.     move.b    #1,d4
  576.  
  577. endincsq    movem.l    (a7)+,d0-d3/a0
  578.     rts
  579.  
  580. ;    Increments value in button (d1,d2). Tests for invalidity. Doesn't increment if 0 and d4.b=0, or if
  581. ;    >0 and d4.b=1. Returns d4.b=0 for latter case.
  582.  
  583. inc    cmpi.w    #-1,d1
  584.     beq    incerr
  585.     cmpi.w    #-1,d2
  586.     beq    incerr
  587.     move.w    Size,d3
  588.     cmp.w    d3,d1
  589.     beq    incerr
  590.     cmp.w    d3,d2
  591.     beq    incerr
  592.     mulu    d1,d3
  593.     add.w    d2,d3
  594.     add.w    d3,d3
  595.     add.w    ntext,d3
  596.     movea.l    TextMem,a0
  597.     move.b    0(a0,d3.w),d0
  598.     cmpi.b    #" ",d0
  599.     bne    incok
  600.     tst.b    d4
  601.     beq    incerr
  602.     move.b    #"1",d0
  603.     bra    endinc
  604. incok    tst.b    d4
  605.     bne    incerr
  606.     addq.b    #1,d0
  607.     cmpi.b    #"5",d0
  608.     bne    endinc
  609.     move.b    #"1",d0
  610. endinc    move.b    d0,0(a0,d3.w)
  611.     rts
  612. incerr    clr.b    d4
  613.     rts
  614.  
  615. ;    Clear the buttons (reset to zero)
  616.  
  617. Clear    movem.l    d0/a0,-(a7)
  618.  
  619.     movea.l    TextMem,a0
  620.     adda.w    ntext,a0
  621.     move.w    Size,d0
  622.     mulu    d0,d0
  623. clearlp    move.b    #" ",(a0)
  624.     adda.w    #2,a0
  625.     subq.w    #1,d0
  626.     bne    clearlp
  627.     bsr    Reset
  628.  
  629.     movem.l    (a7)+,d0/a0
  630.     rts
  631.  
  632. ;    Initialise a new board
  633.  
  634. Shuffle    movem.l    d0-d4/a0-a1,-(a7)
  635.  
  636.     movea.l    TextMem,a0
  637.     movea.l    a0,a3
  638.     move.w    Size,d0
  639.     mulu    d0,d0
  640.     move.w    d0,d3
  641.     add.w    d0,d0
  642.     
  643. wipe    move.b    #" ",(a0)
  644.     adda.w    #2,a0
  645.     subq.w    #1,d0
  646.     bne    wipe
  647.  
  648.     movea.l    a3,a0
  649.     move.w    d3,d1
  650.     move.w    ntext,-(a7)
  651.     clr.w    ntext
  652.  
  653. shuflp    moveq.b    #2,d0
  654.     bsr    GetRand
  655.     move.b    d2,d5            direction to move if square is already occupied
  656.     move.w    d3,d0
  657.     bsr    GetRand
  658. trynext    move.b    d2,d0
  659.     bsr    IncSquare
  660.     tst.b    d4
  661.     bne    wasempty
  662.  
  663.     tst.b    d5
  664.     beq    prevsq
  665.     addq.b    #1,d2
  666.     cmp.b    d3,d2
  667.     bne    trynext
  668.     clr.b    d2
  669.     bra    trynext
  670. prevsq    subq.b    #1,d2
  671.     cmpi.b    #-1,d2
  672.     bne    trynext
  673.     move.b    d3,d2
  674.     subq.b    #1,d2
  675.     bra    trynext
  676.  
  677. wasempty    subq.w    #1,d1
  678.     bne    shuflp
  679.  
  680.     clr.w    Count
  681.  
  682.     move.w    (a7)+,ntext
  683.     movem.l    (a7)+,d0-d4/a0-a1
  684.     rts
  685.  
  686. ;    Initialise the window title bar and move count
  687.  
  688. Reset    clr.w    Count
  689.     movea.l    MyWindow,a0
  690.     lea    MainTxt,a1
  691.     movea.w    #-1,a2
  692.     CALLINT    SetWindowTitles
  693.     rts
  694.  
  695. ;    Check to see if the user has won the game, and set the title bar accordingly
  696.  
  697. TestWin    movea.l    TextMem,a0
  698.     movea.l    a0,a1
  699.     adda.w    ntext,a1
  700.     move.w    Size,d0
  701.     mulu    d0,d0
  702.     subq.w    #1,d0
  703.  
  704. testlp    cmp.w    (a0)+,(a1)+
  705.     dbne    d0,testlp
  706.     cmpi.w    #-1,d0
  707.     beq    win
  708.  
  709.     movea.l    MyWindow,a0
  710.     lea    LoseTxt,a1
  711.     movea.w    #-1,a2
  712.     CALLINT    SetWindowTitles
  713.     rts
  714.  
  715. win    movea.l    MyWindow,a0
  716.     lea    WinTxt,a1
  717.     movea.w    #-1,a2
  718.     CALLINT    SetWindowTitles
  719.     rts
  720.  
  721.     SECTION    Data,DATA
  722.  
  723. IntName    INTNAME
  724. DosName    DOSNAME
  725. GfxName    GRAFNAME
  726. GadName    dc.b    "gadtools.library"
  727.  
  728. DefFont    dc.l    0
  729.     dc.w    0
  730.     dc.b    0,0
  731.  
  732. Size    dc.w    3
  733.  
  734. WinTags    dc.l    WA_Left,50
  735.     dc.l    WA_Top,50
  736.     dc.l    WA_Width
  737. winwidth    dc.l    0
  738.     dc.l    WA_Height
  739. winheight    dc.l    0
  740.     dc.l    WA_IDCMP,CLOSEWINDOW!GADGETUP!VANILLAKEY
  741.     dc.l    WA_Gadgets,glist
  742.     dc.l    WA_Title,MainTxt
  743.     dc.l    WA_DragBar,1
  744.     dc.l    WA_DepthGadget,1
  745.     dc.l    WA_CloseGadget,1
  746.     dc.l    0
  747.  
  748. MainTxt    dc.b    "Aniso",0
  749. WinTxt    dc.b    "Well Done!",0
  750. LoseTxt    dc.b    "Try Again...",0
  751.  
  752. Buttons    dc.w    8,0,0,0
  753.     dc.l    NewTxt,DefFont
  754.     dc.w    200
  755.     dc.l    PLACETEXT_IN,0,BUTTON_KIND
  756.  
  757.     dc.w    0,0,0,0
  758.     dc.l    RetryTxt,DefFont
  759.     dc.w    201
  760.     dc.l    PLACETEXT_IN,0,BUTTON_KIND
  761.  
  762.     dc.w    0,0,0,0
  763.     dc.l    QuitTxt,DefFont
  764.     dc.w    202
  765.     dc.l    PLACETEXT_IN,0,BUTTON_KIND
  766.  
  767.     dc.w    0,0,0,0
  768.     dc.l    0,DefFont
  769.     dc.w    203
  770.     dc.l    PLACETEXT_IN,0,CYCLE_KIND
  771.  
  772. NewTxt    dc.b    "_New",0
  773. RetryTxt    dc.b    "_Retry",0
  774. QuitTxt    dc.b    "_Quit",0
  775.  
  776. Tag1    dc.l    GTTX_Border,1,0
  777.  
  778. Tag2    dc.l    GT_Underscore,"_"
  779.     dc.l    GTCY_Labels,Array
  780.     dc.l    GTCY_Active
  781. CycActive    dc.l    0,0
  782.  
  783. Array    dc.l    a1,a2,a3,a4,a5,a6,0
  784. a1    dc.b    "3x3",0
  785. a2    dc.b    "4x4",0
  786. a3    dc.b    "5x5",0
  787. a4    dc.b    "6x6",0
  788. a5    dc.b    "7x7",0
  789. a6    dc.b    "8x8",0
  790.  
  791.     SECTION    Variables,BSS
  792.  
  793. _IntuitionBase ds.l    1
  794. _DOSBase    ds.l    1
  795. _GadBase    ds.l    1
  796. _GfxBase    ds.l    1
  797.  
  798. ReturnMsg    ds.l    1
  799. SysFont    ds.l    1
  800. ScrFont    ds.l    1
  801. PubScr    ds.l    1
  802. VisInfo    ds.l    1
  803. MyWindow    ds.l    1
  804. MyIdcmp    ds.l    1
  805. CycleGad    ds.l    1
  806. FirstBox    ds.l    1
  807. FirstBut    ds.l    1
  808.  
  809. sfsize    ds.w    1
  810. width    ds.l    1
  811. nwidth    ds.l    1
  812. height    ds.l    1
  813. nheight    ds.l    1
  814. ntext    ds.w    1
  815.  
  816. SizeCopy    ds.w    1
  817. Rand    ds.l    1
  818. GadMem    ds.l    1
  819. TextMem    ds.l    1
  820. Mem1    ds.l    1
  821. Mem2    ds.l    1
  822. Terminate    ds.w    1
  823. Count    ds.w    1
  824.  
  825. glist    ds.l    44
  826.  
  827.     end
  828.